<?php
// +----------------------------------------------------------------------
// | 美胸汇 [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.dongdang.xin All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: tiedong <2547337875@qq.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

use app\portal\model\PortalPostModel;
use cmf\controller\HomeBaseController;

class ArticleController extends HomeBaseController
{

    //更多文章
    public function index()
    {
        $portalPostModel = new PortalPostModel();
        $articleList = $portalPostModel
            ->where('delete_time','=',0)
            ->order('create_time','DESC')
            ->paginate(9);
        $page = $articleList->render();
        $this->assign('articleList',$articleList);
        $this->assign('page', $page);
        return $this->fetch(':newsList');
    }

    //文章详情
    public function articleDetail()
    {
        $articleId  = $this->request->param('id', 0, 'intval');
        if (empty($articleId)) {
            $this->error("参数有误！");
        }
        $portalPostModel = new PortalPostModel();
        $article = $portalPostModel
            ->where('id','=',$articleId)
            ->find();
        if ( empty($article) ) {
            $this->error("改文章已经删除！");
        }
        $this->assign('article',$article);
        return $this->fetch(':newsDetail');

    }
}
